import 'package:lcapp/api/request/api_client.dart';
import 'package:lcapp/api/request/response_data.dart';

class CommonAPI {

  static Future<ResponseData> getAppUpgrade(Map<String,dynamic> map) async {
    ResponseData responseData = await ApiClient.get("/api/update/app",queryParameters: map);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getBaseParams() async {
    ResponseData responseData = await ApiClient.post("/api/param/paramList",data: {'page':1,'size':99});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getCommentList(int id,int page,int size) async {
    ResponseData responseData = await ApiClient.post("/api/comment/load",data: {"id":id,'page':page,'size':size});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getCommentReplies(int id,int page,int size) async {
    ResponseData responseData = await ApiClient.post("/api/commentReply/load",data: {"id":id,'page':page,'size':size});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> saveComment(int id,int type,String content) async {
    ResponseData responseData = await ApiClient.post("/api/comment/save",data: {"id":id,'type':type,'content':content});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> saveCommentReply(int id,String content) async {
    ResponseData responseData = await ApiClient.post("/api/commentReply/save",data: {"id":id,'content':content});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> commentLike(int commentId,int operation) async {
    ResponseData responseData = await ApiClient.post("/api/comment/like",data: {"commentId":commentId,'operation':operation});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> commentReplyLike(int commentReplyId,int operation) async {
    ResponseData responseData = await ApiClient.post("/api/commentReply/like",data: {"commentReplyId":commentReplyId,'operation':operation});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> share(int type,int entryId) async {
    ResponseData responseData = await ApiClient.post("/api/share/addShare",data: {"type":type,'entryId':entryId});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> regDeviceToken(String deviceToken,int clientType,int userId) async {
    ResponseData responseData = await ApiClient.post("/api/device/savedevice",data: {"deviceToken":deviceToken,'clientType':clientType,'userId':userId});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getVideoUploadToekn(String title,String type) async {
    ResponseData responseData = await ApiClient.get("/api/video/getUploadVideoToekn",queryParameters: {"title":title,'type':type,});
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getImgUploadToekn(String title) async {
    ResponseData responseData = await ApiClient.get("/api/video/getUploadImgToekn",queryParameters: {"title":title,});
    return ResponseData.createFrom(responseData, responseData.data);
  }

}